package main

import (
	"fmt"
	"math"
)

func maxSubArray(nums []int) int {
	if len(nums) == 0 {
		return 0
	}
	currentMax, globalMax := nums[0], nums[0]
	for i := 1; i < len(nums); i++ {
		currentMax = int(math.Max(float64(nums[i]), float64(currentMax+nums[i])))
		globalMax = int(math.Max(float64(currentMax), float64(globalMax)))

	}
	return globalMax
}
func main() {
	//[-2, 11, -4, 13, -5, -2]
	s := []int{-2, 11, -4, 13, -5, -2}
	max := maxSubArray(s)
	fmt.Println(max)

}
